package br.uefs.cedoc.controle.subserie;

import br.uefs.cedoc.controle.*;
import br.uefs.cedoc.db.exception.DBConnectionException;
import javax.servlet.http.HttpServletRequest;
import br.uefs.cedoc.db.*;
import br.uefs.cedoc.db.subserie.DBSubserie;
import br.uefs.cedoc.entidades.*;
import java.sql.SQLException;



public class UpdateSubserieCommand implements Command {
	  private String next;

	  public UpdateSubserieCommand(String next) {
	    this.next = next;
	  }

    public String execute(HttpServletRequest req) throws CommandException {
        try {
            
            DBSubserie dbsubserie = new DBSubserie();
            SubserieBean subserie = new SubserieBean();
            subserie.setIdSubserie(Integer.parseInt(req.getParameter("id")));
            subserie.setSubserie(req.getParameter("subserie"));
            //System.out.println("Ob subserie Id= "+subserie.getIdsubserie()+" SEC= "+subserie.getSubserie());
            dbsubserie.editarSubserie(subserie);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } catch (DBConnectionException ex) {
                ex.printStackTrace();
            }
            req.setAttribute("status.msg", "Atualizada com sucesso!");
            
            return next;

    }



	}
